package model.persistence.daos;

import model.exceptions.EntityInvalidaException;
import model.persistence.HibernateSessionFactory;

import org.hibernate.Session;

public class GenericDAO
{
	public static void save(Object entity) throws EntityInvalidaException
	{
		if (entity != null)
		{
			Session session = HibernateSessionFactory.getSessionFactory().openSession();
			session.saveOrUpdate(entity);
			session.flush();
			session.close();
		}
		else
		{
			throw new EntityInvalidaException("La entidad a persistir no esta instanciada");
		}
	}
}
